<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html"
      xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
   <script src="vue.js"></script>
   <script src="axios.js"></script>
   <script src="util.js"></script>
</head>
<body>

<div id="app">
<form>
    <table border="1">
        <tr>
            <td>编号</td>
            <td>姓名</td>
            <td>年龄</td>
            <td>工资</td>
            <td>手机号</td>
            <td>地址</td>
            <td>操作</td>
        </tr>
        <tr v-for="p in page.records">
            <td>{{p.id}}</td>
            <td>{{p.name}}</td>
            <td>{{p.age}}</td>
            <td>{{p.salary}}</td>
            <td>{{p.phone}}</td>
            <td>{{p.did}}</td>
            <td>
                <button @click="up(p.id)">修改</button>
                <button @click="del(p.id)">删除</button>
                <a @click="add()">添加</a>
            </td>
        </tr>
    </table>

    <a href="#" @click="findPage(1)">首页</a>
    <a href="#" @click="findPage(page.prePage)">上一页</a>
    <a href="#" @click="findPage(page.nextPage)">下一页</a>
    <a href="#" @click="findPage(page.lastPage)">尾页</a>

</form>
</div>

<script>
    new Vue({
        el:"#app",
        data:{
            page:{}
        },
        methods:{
            up(id){
                location.href="update.html?id="+id;
            },
            add(){
                location.href="add.html";
            },
            del(id){
                axios.get("/emp/del?id="+id).then(res=>{
                    this.findPage(1);
                })
            },
            findPage(pageIndex){
                axios.get("/emp/findPage?pageIndex="+pageIndex).then(res=>{
                    this.page = res.data
                })
            }
        },
        created(){
            this.findPage(1);
        }
    })
</script>

</body>
</html>